package cn.itcast.dao;


import cn.itcast.entity.OrderQueryPageBean;
import cn.itcast.pojo.Order;
import cn.itcast.pojo.Setmeal;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

public interface OrderListDao {
    //分页查询
    @SelectProvider(type = cn.itcast.util.SelectSQLProvider.class,method = "selectSQL")
    ArrayList<Order> findByPage(OrderQueryPageBean orderQueryPageBean);

    //根据预约id查询
    @Select("select * from t_order where id=#{id}")
    Order findById(Long id);

    //更新
    @Update("update t_order set name=#{name},idCard=#{idCard},birthday=#{birthday},phoneNumber=#{phoneNumber},sex=#{sex},married=#{married},orderDate=#{orderDate},setmealId=#{setmealId} where id=#{id}")
    int update(Order order);

    //添加
    @Insert("insert into t_order (id,name,idCard,birthday,phoneNumber,sex,married,orderDate,addressId,setmealId,memberId) values (#{id},#{name},#{idCard},#{birthday},#{phoneNumber},#{sex},#{married},#{orderDate},#{addressId},#{setmealId},#{memberId})")
    int insert(Order order);

    //修改预约状态
    @Update("update t_order set arrival=#{arrival} where id=#{id}")
    void changeOrderStatus(@Param("id") Long id,@Param("arrival") Integer arrival);

    //根据用户id查询订单
    @Select("select * from t_order where memberId=#{id}")
    List<Order> findByMemberId(Long id);

    //修改支付状态
    @Update("update t_order set payStatus=1 where id=#{orderId}")
    void updatePayStatus(String orderId);

    //查询套餐信息
    @Select("select * from t_setmeal where id=#{setmealId}")
    Setmeal findSetmeal(Integer setmealId);
}
